package com.oracle.compents;

public class ApiResponse<T> {

    private String msg;
    private Long code;
    private T data;

    /**
     * 操作成功
     * @return
     */
    public static<T> ApiResponse<T> success(T t){
        ApiResponse<T> response = new ApiResponse<T>(StatusEunms.SUCCESS.getMsg(), StatusEunms.SUCCESS.getCode());
        response.setData(t);
        return response;
    }

    /**
     * 操作失败
     * @return
     */
    public static<T> ApiResponse<T> failed(T t){
        ApiResponse<T> response = new ApiResponse<T>(StatusEunms.FAILED.getMsg(), StatusEunms.FAILED.getCode());
        response.setData(t);
        return response;
    }

    public ApiResponse() {
    }

    public ApiResponse(String msg, Long code) {
        this.msg = msg;
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getCode() {
        return code;
    }

    public void setCode(Long code) {
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
